{% extends "myadmin/base.html" %}


{% block mainbody %}
<h3>
	主机管理&nbsp;主机列表
</h3>

<!--主机查询条件form开始-->
<form class="form-inline" action="{% url 'myadmin_hosts_index' 1 %}" method="get">
	<label>关键字：</label>
	<input type="text" name="keyword" value="{{request.GET.keyword}}" class="input-small" placeholder="标签/IP地址">
    <button type="submit" class="btn">搜索</button>
    <a href="{% url 'myadmin_hosts_index' 1 %}" class="btn">全部</a>
    <a href="{% url 'myadmin_hosts_add' %}" class="btn">添加主机</a>
</form>
<!--主机查询条件form结束-->

<!--主机查询结果表格开始-->
<table class="table table-bordered table-striped">
	<thead>
		<tr>
			<th>ID</th>
			<th>标签</th>
			<th>IP地址</th>
			<th>CPU</th>
			<th>内存</th>
			<th>硬盘</th>
			<th>状态</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody>
		{% for item in hostslist %}
		<tr>
			<td>{{ item.id }}</td>
			<td>{{ item.tag }}</td>
			<td>{{ item.ip }}</td>
			<td>{{ item.cpu }}核</td>
			<td>{{ item.memory }}G</td>
			<td>{{ item.disk }}G</td>
			<td>
                {% if item.state == 1 %}
                    <span style="color:green">运行中</span>
                {% else %}
                    <span style="color:#666">暂挂</span>
                {% endif %}
			</td>
			<td>
				<a href="{% url 'myadmin_usage_index' item.id %}" class="btn btn-mini btn-success">查看</a>
				<a href="{% url 'myadmin_hosts_edit' item.id %}" class="btn btn-mini btn-primary">编辑</a>
				<a href="javascript:doDel('{% url 'myadmin_hosts_del' item.id %}')" class="btn btn-mini btn-danger">删除</a>
			</td>
		</tr>
		{% endfor %}
	</tbody>
</table>
<!--主机查询结果表格结束-->

<!--页码开始-->
<div class="pagination">
    <ul>
        <li>
            <a href="{% url 'myadmin_hosts_index' pIndex|add:-1 %}?{{ mywhere|join:'&' }}">&laquo;</a>
        </li>
        {% for p in plist %}
        <li {% if pIndex == p %}class="active"{% endif %}>
            <a href="{% url 'myadmin_hosts_index' p %}?{{ mywhere|join:'&' }}">{{p}}</a>
        </li>
        {% endfor %}
        <li>
            <a href="{% url 'myadmin_hosts_index' pIndex|add:1 %}?{{ mywhere|join:'&' }}">&raquo;</a>
        </li>

    </ul>
</div>
<!--页码结束-->

<script type="text/javascript">
    //删除主机信息时确认是否要删除
	function doDel(url){
		if (confirm("删除后将不能监控主机运行状态，确定要删除吗？")){
			window.location=url
		}
	}
</script>

{% endblock %}